<template>
  <div>
    <h2>I am Home</h2>
    <p>Content</p>
    <router-link to="/home/news">新闻</router-link>
    <router-link to="/home/messages">消息</router-link>

    <router-view></router-view>

    <h2>{{message}}</h2>
  </div>
</template>

<script>
export default {
  name: "Home",
  data() {
    return {
      message: 'Hello',
      path: '/home/news'
    }
  },
  created(){
    // this.$router.push('/home/news');
  },
  activated(){
    // console.log("activated");
    this.$router.push(this.path);
  },
  // deactivated() {
  //   this.path = this.$route.path;
  // }
  beforeRouteLeave (to, from, next) {
    console.log(this.$route.path);
    this.path = this.$route.path;
    next();
  }
}

</script>

<style scoped>

</style>